/*
 * Sesame Inc.
 * Copyright (c) 2009 All Rights Reserved.
 */
package com.sesame.daoimpl;

import java.util.List;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.sesame.dao.AdminDAO;
import com.sesame.domain.Admin;

/**
 * @author shubeta
 * 
 */
public class AdminDAOImpl extends SqlMapClientDaoSupport implements AdminDAO {

    public void addAdmin(Admin admin) {
        getSqlMapClientTemplate().insert("addAdmin", admin);
    }

    public void deleteAdminById(Integer id) {
        getSqlMapClientTemplate().delete("deleteAdminById", id);
    }

    @SuppressWarnings("unchecked")
    public List<Admin> getAllAdmin() {
        return (List<Admin>) getSqlMapClientTemplate().queryForList(
                "getAllAdmin");
    }

    public Admin getAdminByUserName(String userName) {
        return (Admin) getSqlMapClientTemplate().queryForObject(
                "getAdminByUserName", userName);
    }

    public Admin getAdminById(Integer id) {
        return (Admin) getSqlMapClientTemplate().queryForObject("getAdminById",
                id);
    }

    public void updateAdminPassword(Admin admin) {
        getSqlMapClientTemplate().update("updateAdminPassword", admin);
    }

}